//----------------------------------------------------------------------------
// helpcmd.cpp
//
// Display help and usage stuff
//
// Copyright (C) 2011 Neil Butterworth
//----------------------------------------------------------------------------

#include <iostream>
#include "command.h"

using namespace std;

namespace Swine {

//----------------------------------------------------------------------------

class HelpCmd : public Command {

	public:

		HelpCmd();
		virtual int Execute( CmdLine & cl ) const;

};

static AddCommand <HelpCmd> cmd1_;

HelpCmd :: HelpCmd() : Command( "help", "the help command" ) {
}

int HelpCmd :: Execute( CmdLine & cl ) const {

	if ( cl.Argc() <= 2 ) {
		cout <<
			"swine is a collection of dialogs for use in scripts\n"
			"Version 0.4\n"
			"Copyright (C) 2011 Neil Butterworth\n"
			"\n"
			"The following commands are implemented, or partially so:\n\n";

			CommandDict::Instance().WriteHelp();

		cout <<
			"\nuse 'swine help cmd' for help on a specific command.";
		cout << endl;
	}
	else {
		string help = CommandDict::Instance().GetLongHelp( cl.Argv(2) );
		cout << help << endl;
	}
	return 0;
}


//----------------------------------------------------------------------------

} // namespace
